package com.lile.collection;

import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;

/*
 * 特有功能：
 * 		A:添加元素
 * 			public void addElement(Object obj)		--		add(Object obj)
 * 		B:获取元素
 *			public Object elementAt(int index)		--		get(int index)
 *			public Enumeration elements()			--		Iterator iterator()
 *						hasMoreElements()							hasNext()
 *						nextElement()								next()
 *
 *		JDK版本升级：
 *			A:安全
 *			B:效率
 *			C:简化书写
 */
public class VectorDemo {

	public static void main(String[] args) {
		test1();
	}

	public static void test1() {
		Collection<String> c = new Vector<String>();
		List<String> list = new Vector<String>();

		Vector<String> vector = new Vector<String>();
		vector.addElement("hello");
		vector.addElement("world");
		vector.addElement("java");

		// System.out.println(vector.elementAt(0));

		for (int i = 0; i < vector.size(); i++) {
			String s = (String) vector.elementAt(i);
			System.out.println(s);
		}

		System.out.println("===========");

		// 类似迭代器的方式
		Enumeration<String> en = vector.elements();
		while (en.hasMoreElements()) {
			String s = (String) en.nextElement();
			System.out.println(s);
		}

		System.out.println("vector:" + vector);
	}

}
